package com.nowar.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: 谢无殇。
 * @Date : 2023-08-26 23:44
 */
@Component
public class NowarHandlerInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        // 获取请求头信息
        String headerInfo = request.getHeader("Header-Info");
        System.out.println(headerInfo);
        // 解析请求头信息
        // ...
        return true; // 返回true继续执行请求处理，返回false则不执行请求处理

    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("111");
    }

}
